
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module http.login
* @author: Hjava
* @description: HTTP模块的登录相关接口
* @since: 2018-07-22 15:53:45
*/
var http_core_1 = __webpack_require__(/*! _http/http.core */ "./src/core/http/http.core.ts");
var constant_1 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
var deviceInfo_1 = __webpack_require__(/*! _util/deviceInfo */ "./src/core/utils/deviceInfo.ts");
var userData_1 = __webpack_require__(/*! _util/userData */ "./src/core/utils/userData.ts");
exports.default = {
    getVisitorUidAndToken: function (options) {
        options.data = {
            ai: userData_1.default.get('appId'),
            dt: deviceInfo_1.default.deviceType
        };
        http_core_1.default.request('/account/api/v3/web/login/anonymity', options, true);
    },
    /**
     * Web SDK自身使用此函数
     *
     * @param {ObjectInterface} [options={data: {}}]
     */
    getRemoteLoginAddr: function (options) {
        if (options === void 0) { options = { data: {} }; }
        var _success = options.success;
        var supportCr = userData_1.default.get('useChatRoomURL') ? true : false;
        options.data = __assign(__assign({}, options.data), { uid: userData_1.default.get('uid'), ai: userData_1.default.get('appId'), dt: deviceInfo_1.default.deviceType, 
            // lt中3代表wss，2代表ws，具体文档见：https://km.sankuai.com/page/42183447
            lt: userData_1.default.get('useHTTPS') || userData_1.default.get('env') === constant_1.ENV.ONLINE ? 3 : 2, cnt: 1, supportCr: supportCr });
        options.success = function (_a) {
            var rescode = _a.rescode, data = _a.data;
            if (rescode === 0) {
                _success({
                    websocketAddr: data.websocketAddr.filter(function (url) {
                        return url;
                    }),
                    longPollingAddr: data.longPollingAddr.filter(function (url) {
                        return url;
                    })
                });
            }
            else {
                _success({
                    websocketAddr: [],
                    longPollingAddr: []
                });
            }
        };
        http_core_1.default.request('/dxlvs/open/v2/lgservers/json', options, true);
    }
};


//# sourceURL=webpack://MTDX/./src/core/http/http.login.ts?